package com.hegongda.okcmall.product.web;

import com.hegongda.okcmall.product.service.SkuInfoService;
import com.hegongda.okcmall.product.vo.ItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author liueidong
 * @create 2021-03-21 15:58
 */
@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String itemPage(@PathVariable("skuId") String skuId, Model model){
        // 根据sku 查询出相关的信息
        ItemVo itemVo = skuInfoService.getItemDetailBySkuId(skuId);
        model.addAttribute("items", itemVo);
        return "item";
    }
}
